﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BSWXBLPDA
{
    public partial class Main : Form
    {
       
        private LoginReference.Registration Reg = new BSWXBLPDA.LoginReference.Registration();

        private string ID;
        private string name;

        public Main()
        {
            InitializeComponent();
        }
               

        public Main(string _ID,string _name)
        {
            InitializeComponent();
            this.ID = _ID;
            this.name = _name;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Login iw = new Login();
            iw.Show();
            this.Hide();
        }
        //根据id判断权限
        public string JudgeAuthority()
        {
            string result = string.Empty;
            try
            {
                result = Reg.GetPDAAuthority(this.ID);
            }
            catch (Exception ex)
            {
                MessageBox.Show("程序出错！", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button3);
            }
            return result;
        }

        public void SetENABLE()
        {
            btnSCANF.Enabled = false;
            btnRESCAN.Enabled = false;
        }

        private void Main_Load(object sender, EventArgs e)
        {
           string action = string.Empty;
           SetENABLE();
           action = JudgeAuthority();
           if (action != null && action != "")
           {
               string[] data = action.Split(',');
               for (int i = 0; i < data.Length; i++)
               {
                   if (data[i] == "SCANF")
                   {
                       btnSCANF.Enabled = true;
                   }
                   else if (data[i] == "RESCAN")
                   {
                       btnRESCAN.Enabled = true;
                   }
               }
           }
        }

        private void btnSCANF_Click(object sender, EventArgs e)
        {
            SCAN iw = new SCAN(this.ID, this.name);
            iw.Show();
            this.Hide();

        }

        private void btnRESCAN_Click(object sender, EventArgs e)
        {
            RESCANF iw = new RESCANF(this.ID, this.name);
            iw.Show();
            this.Hide();
        }

        //private void btnSCANF_Click(object sender, EventArgs e)
        //{
        //    RESCAN iw = new RESCAN(this.ID, this.name);
        //    iw.Show();
        //    this.Hide();

        //}



    }
}